package com.atguigu.gulimail.ware.exception;

import com.atguigu.common.exception.BizException;
import com.atguigu.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Guo 2022/9/14 16:52:24
 */
@RestControllerAdvice(basePackages = "com.atguigu.gulimail.ware.controller")
@Slf4j
public class WareExceptionAdvice {


    @ExceptionHandler(value = BizException.class)
    public R handleVaildException2(BizException throwable){
        log.error("数据校验出现问题:{},错误码:{},异常类型:{}",throwable.getMessage(),throwable.getCode(),throwable.getClass());
        log.error("错误：",throwable);
        return R.error(throwable.getCode(),throwable.getMsg());
    }


}
